package tianwang.services.typeddependencies;

import java.util.Collection;

import tianwang.utils.stanford.StanfordUtils;

import edu.stanford.nlp.parser.lexparser.LexicalizedParser;
import edu.stanford.nlp.trees.GrammaticalStructure;
import edu.stanford.nlp.trees.GrammaticalStructureFactory;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.trees.TreebankLanguagePack;
import edu.stanford.nlp.trees.TypedDependency;
/**
 * Stanford 的 TypedDependencies分析器
 */
public class TypedDependenciesStanford{

	public Collection<TypedDependency> typedDependencies(String sentence) {
		
		LexicalizedParser lp = StanfordUtils.getLexicalizedParser();
		TreebankLanguagePack tlp = StanfordUtils.getTreebankLanguagePack();
 
		GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
		Tree parse = lp.apply(sentence);
		GrammaticalStructure gs = gsf.newGrammaticalStructure(parse);
//		Collection<TypedDependency> tdl = gs.typedDependenciesCCprocessed();
		return gs.allTypedDependencies();
		
	}
}
